package redisInit

import (
	"gin_chat_demo/config/zap"
	"gin_chat_demo/global"
	"github.com/go-redis/redis"
)

func InitRedis(addr, password string, db int) {
	global.RedisClient = redis.NewClient(&redis.Options{
		Addr:     addr,
		Password: password, // no password set
		DB:       db,       // use default DB
	})
	_, err := global.RedisClient.Ping().Result()
	if err != nil {
		zap.Logger.Errorf("初始化redis失败 err: %v", err)
		panic(err)
	}
}
